package jobs;

import java.util.LinkedList;
import java.util.List;

import controllers.Topics;

import models.Eentity;
import models.Idea;
import models.Organization;
import models.Plan;
import models.Role;
import models.Topic;
import models.User;
import play.jobs.Job;
import play.jobs.OnApplicationStart;

@OnApplicationStart
public class Bootstrap extends Job {

	 public void doJob() {
		 
/*		 
		
			LinkedList attributes= 
				new LinkedList(); 
				attributes.add(
				"fname"); 
				attributes.add(
				"lname"); 
				attributes.add(
				"username"); 
				attributes.add(
				"password"); 
				attributes.add(
				"0180"); 
				attributes.add(
				"fadress"); 
				attributes.add(
				"email"); 
				User user = 
				new User(attributes); 
				LinkedList attributes2= 
				new LinkedList(); 
				attributes2.add(
				"fname2"); 
				attributes2.add(
				"lname2"); 
				attributes2.add(
				"username2"); 
				attributes2.add(
				"password2"); 
				attributes2.add(
				"01802"); 
				attributes2.add(
				"fadress2"); 
				attributes2.add(
				"email2"); 
				User user2 = 
				new User(attributes2); 
				Organization org = 
				new Organization("organization1",user,"description1","public"); 
				Eentity e1 = 
				new Eentity("Entity1","noDescription"); 
				user.getEntityList().add(e1);
				e1.setOwner(user);
				Role role = 
				new Role(e1,"Creator"); 
				user.getRoleList().add(role);
				role.setUsers(user);
				//org.save();
				Role role3= new Role(org,"lead");
				e1.setOrganization(org);
				org.getAllEntities().add(e1);
				org.setLead(user2);
				user.getOrganizationList().add(org);
				user.getRoleList().add(role3);
				role3.setUsers(user2);
				
			
				
				Topic topic = new Topic(user2,"topic1","nodetails","public","today");
			  LinkedList<Topic>topics= new LinkedList();
				topic.setEntity(e1);
				topics.add(topic);
			  e1.setTopics(topics);
			    System.out.println(topic.getContent());
			    System.out.println(topic.getId());
			    System.out.println(topic.getInitiator().getfName());
			   
	           
			LinkedList<User> temp= new LinkedList();
			temp.add(user2);
			org.getTopics().add(topic);
			topic.setOrganization(org);
			topic.setInitiator(user2);
			user2.getTopicList().add(topic);
			Role role2= new Role(topic,"creator");
			user2.getRoleList().add(role2);
			role2.setUsers(user2);
			Idea i1= new Idea("title","nodesc",false,topic,temp);
			System.out.println(i1.getTopic().getTitle());
			 
			 topic.getIdeas().add(i1);
			 i1.setTopic(topic);
			 
			 Plan p = new Plan("Super Plan",false,new LinkedList<String>());
			 
//			
//		
//			
//		
			 try {
			 user.save();
			 p.save();
			org.save();
			user2.save();
			topic.save();
			i1.save();
			e1.save();
			 role.save();
			role2.save();
			role3.save();
			System.out.println(i1.id);
			long x=1;
			
			 }
			 
			 catch (Exception e) {
				 
			 }
			
//			//			//Topics.show(x);
//		 
//	       //org.hsqldb.util.DatabaseManagerSwing.main(new String[] { "--url", 
//	      //		   "jdbc:hsqldb:mem:playembed", "--noexit" });
//	    
 * 
 */
	 }
}
